package com.duckclouddrive.mappers;

import com.duckclouddrive.entity.po.FileInfo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 文件信息 数据库操作接口
 */
public interface FileInfoMapper<T,P> extends BaseMapper<T,P> {

	/**
	 * 根据FileIdAndUserId更新
	 */
	 Integer updateByFileIdAndUserId(@Param("bean") T t,@Param("fileId") String fileId,@Param("userId") String userId);


	/**
	 * 根据FileIdAndUserId删除
	 */
	 Integer deleteByFileIdAndUserId(@Param("fileId") String fileId,@Param("userId") String userId);


	/**
	 * 根据FileIdAndUserId获取对象
	 */
	 T selectByFileIdAndUserId(@Param("fileId") String fileId,@Param("userId") String userId);

	void updateFileStatusWithOldStatus(@Param("fileId") String fileId, @Param("userId") String userId, @Param("bean") T t,
									   @Param("oldStatus") Integer oldStatus);

	void updateFileDelFlagBatch(@Param("bean") FileInfo fileInfo,
								@Param("userId") String userId,
								@Param("filePidList") List<String> filePidList,
								@Param("fileIdList") List<String> fileIdList,
								@Param("oldDelFlag") Integer oldDelFlag);
	void delFileBatch(@Param("userId") String userId,
					  @Param("filePidList") List<String> filePidList,
					  @Param("fileIdList") List<String> fileIdList,
					  @Param("oldDelFlag") Integer oldDelFlag);


	/*
	  * 根据userId获取已使用的空间
	 * */
	 Long selectUseSpace(@Param("userId") String userId);

	 /*
	 * 根据用户id删除文件
	 * */
	void deleteFileByUserId(@Param("userId") String userId);
}
